package com.kcht.itsed.mws.persist.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.kcht.itsed.mws.extendmodel.jpa.SubscriberEntity;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Set;

public interface ISubscriberDao extends BaseMapper<SubscriberEntity> {

	@Select("select * from T_SUBSCRIBER")
	List<SubscriberEntity> loadAllSubscriberEntities();

	@Select("select count(*) from T_SUBSCRIBER where SUBSCRIBER_URL=#{subscriberUrl}")
	boolean isSubscriberAlive(String subscriberUrl);

	/**
	 * 是否关联了指定的ec规则
	 * */
	@Select("select count(*) from T_SUBSCRIBER where T_EVENT_CYCLE_SPEC_id=#{eventCycleSpecId}")
	boolean isAssociatedEc(Long  eventCycleSpecId);

	/**
	 * 加载所有关联了指定ec规则的sc
	 * */
	@Select("select * from T_SUBSCRIBER where T_EVENT_CYCLE_SPEC_id=#{eventCycleSpecId}")
	Set<SubscriberEntity> loadAssociatedSubscriber(Long  eventCycleSpecId);
}
